package com.ruoyi.lc.domain;

import java.util.List;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.lc.util.LcDataModelUtil;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 数据建模对象 lc_datamodel_define
 * 
 * @author qibotian
 * @date 2025-01-07
 */

@Data
@EqualsAndHashCode(callSuper=false)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class LcDatamodelDefine extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** ID */
    private Long id;

    /** 标识 */
    @Excel(name = "标识")
    private String code;

    /** 标题 */
    @Excel(name = "标题")
    private String title;
    
    @Excel(name = "标题（维护中）")
    private String whzTitle;

    /** 所属分组 */
    private String groupCode;
    
    /** 所属分组 */
    @Excel(name = "所属分组")
    private String groupTitle;

    /** 状态 */
    @Excel(name = "状态")
    private String state;

    /** 类型 */
    @Excel(name = "类型")
    private String type;

    /** 排序 */
    @Excel(name = "排序")
    private Long orderNum;
    
    @Excel(name = "表描述")
    private String desc;
    
    @Excel(name = "表描述（维护中）")
    private String whzDesc;
    
    private List<LcDatamodelColumn> columns;
    
    public LcDatamodelColumn findColumnByCode(String columnCode) {
    	columnCode = columnCode.toUpperCase();
    	if(columns == null) {
    		columns = LcDataModelUtil.findColumnsFromDesc(getDesc());
    	}
    	
    	for(LcDatamodelColumn c : columns) {
    		if(c.getCode().equals(columnCode)) {
    			return c;
    		}
    	}
    	return null;
    }
    
    
}
